home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / htmlparser / nsIHTMLContentSink.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  11KB  |  331 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is Mozilla Communicator client code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37. #ifndef nsIHTMLContentSink_h___
  38. #define nsIHTMLContentSink_h___
  39.  
  40. /**
  41.  * MODULE NOTES:
  42.  * @update  gess 4/1/98
  43.  * 
  44.  * This file declares the concrete HTMLContentSink class.
  45.  * This class is used during the parsing process as the
  46.  * primary interface between the parser and the content
  47.  * model.
  48.  *
  49.  * After the tokenizer completes, the parser iterates over
  50.  * the known token list. As the parser identifies valid 
  51.  * elements, it calls the contentsink interface to notify
  52.  * the content model that a new node or child node is being
  53.  * created and added to the content model.
  54.  *
  55.  * The HTMLContentSink interface assumes 4 underlying
  56.  * containers: HTML, HEAD, BODY and FRAMESET. Before 
  57.  * accessing any these, the parser will call the appropriate
  58.  * OpennsIHTMLContentSink method: OpenHTML,OpenHead,OpenBody,OpenFrameSet;
  59.  * likewise, the ClosensIHTMLContentSink version will be called when the
  60.  * parser is done with a given section.
  61.  *
  62.  * IMPORTANT: The parser may Open each container more than
  63.  * once! This is due to the irregular nature of HTML files.
  64.  * For example, it is possible to encounter plain text at
  65.  * the start of an HTML document (that preceeds the HTML tag).
  66.  * Such text is treated as if it were part of the body.
  67.  * In such cases, the parser will Open the body, pass the text-
  68.  * node in and then Close the body. The body will likely be
  69.  * re-Opened later when the actual <BODY> tag has been seen.
  70.  *
  71.  * Containers within the body are Opened and Closed
  72.  * using the OpenContainer(...) and CloseContainer(...) calls.
  73.  * It is assumed that the document or contentSink is 
  74.  * maintaining its state to manage where new content should 
  75.  * be added to the underlying document.
  76.  *
  77.  * NOTE: OpenHTML() and OpenBody() may get called multiple times
  78.  *       in the same document. That's fine, and it doesn't mean
  79.  *       that we have multiple bodies or HTML's.
  80.  *
  81.  * NOTE: I haven't figured out how sub-documents (non-frames)
  82.  *       are going to be handled. Stay tuned.
  83.  */
  84. #include "nsIParserNode.h"
  85. #include "nsIContentSink.h"
  86. #include "nsHTMLTags.h"
  87.  
  88. #define NS_IHTML_CONTENT_SINK_IID \
  89.  { 0x59929de5, 0xe60b, 0x48b1,{0x81, 0x69, 0x48, 0x47, 0xb5, 0xc9, 0x44, 0x29}}
  90.  
  91. #if defined(XP_MAC) || defined(WINCE) 
  92. #define MAX_REFLOW_DEPTH  75    //setting to 75 to prevent layout from crashing on mac. Bug 55095.
  93.                                 //We will also change this for WinCE as it usually has a strict
  94.                                 //memory upper limit (no vm, ~32mb)
  95. #else
  96. #define MAX_REFLOW_DEPTH  200   //windows and linux (etc) can do much deeper structures.
  97. #endif
  98.  
  99. class nsIHTMLContentSink : public nsIContentSink 
  100. {
  101. public:
  102.  
  103.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTML_CONTENT_SINK_IID)
  104.  
  105.   /**
  106.    * This method gets called by the parser when it encounters
  107.    * a title tag and wants to set the document title in the sink.
  108.    *
  109.    * @update 4/1/98 gess
  110.    * @param  nsString reference to new title value
  111.    */     
  112.   NS_IMETHOD SetTitle(const nsString& aValue) = 0;
  113.  
  114.   /**
  115.    * This method is used to open the outer HTML container.
  116.    *
  117.    * @update 4/1/98 gess
  118.    * @param  nsIParserNode reference to parser node interface
  119.    */     
  120.   NS_IMETHOD OpenHTML(const nsIParserNode& aNode) = 0;
  121.  
  122.   /**
  123.    * This method is used to close the outer HTML container.
  124.    *
  125.    */     
  126.   NS_IMETHOD CloseHTML() = 0;
  127.  
  128.   /**
  129.    * This method is used to open the only HEAD container.
  130.    *
  131.    * @update 4/1/98 gess
  132.    * @param  nsIParserNode reference to parser node interface
  133.    */     
  134.   NS_IMETHOD OpenHead(const nsIParserNode& aNode) = 0;
  135.  
  136.   /**
  137.    * This method is used to close the only HEAD container.
  138.    */     
  139.   NS_IMETHOD CloseHead() = 0;
  140.   
  141.   /**
  142.    * This method is used to open the main BODY container.
  143.    *
  144.    * @update 4/1/98 gess
  145.    * @param  nsIParserNode reference to parser node interface
  146.    */     
  147.   NS_IMETHOD OpenBody(const nsIParserNode& aNode) = 0;
  148.  
  149.   /**
  150.    * This method is used to close the main BODY container.
  151.    *
  152.    */     
  153.   NS_IMETHOD CloseBody() = 0;
  154.  
  155.   /**
  156.    * This method is used to open a new FORM container.
  157.    *
  158.    * @update 4/1/98 gess
  159.    * @param  nsIParserNode reference to parser node interface
  160.    */     
  161.   NS_IMETHOD OpenForm(const nsIParserNode& aNode) = 0;
  162.  
  163.   /**
  164.    * This method is used to close the outer FORM container.
  165.    *
  166.    */     
  167.   NS_IMETHOD CloseForm() = 0;
  168.  
  169.   /**
  170.    * This method is used to open a new MAP container.
  171.    *
  172.    * @update 4/1/98 gess
  173.    * @param  nsIParserNode reference to parser node interface
  174.    */     
  175.   NS_IMETHOD OpenMap(const nsIParserNode& aNode) = 0;
  176.  
  177.   /**
  178.    * This method is used to close the MAP container.
  179.    *
  180.    */     
  181.   NS_IMETHOD CloseMap() = 0;
  182.         
  183.   /**
  184.    * This method is used to open the FRAMESET container.
  185.    *
  186.    * @update 4/1/98 gess
  187.    * @param  nsIParserNode reference to parser node interface
  188.    */     
  189.   NS_IMETHOD OpenFrameset(const nsIParserNode& aNode) = 0;
  190.  
  191.   /**
  192.    * This method is used to close the FRAMESET container.
  193.    *
  194.    */     
  195.   NS_IMETHOD CloseFrameset() = 0;
  196.  
  197.   /**
  198.    * This gets called when handling illegal contents, especially
  199.    * in dealing with tables. This method creates a new context.
  200.    * 
  201.    * @update 04/04/99 harishd
  202.    * @param aPosition - The position from where the new context begins.
  203.    */
  204.   NS_IMETHOD BeginContext(PRInt32 aPosition) = 0;
  205.   
  206.   /**
  207.    * This method terminates any new context that got created by
  208.    * BeginContext and switches back to the main context.  
  209.    *
  210.    * @update 04/04/99 harishd
  211.    * @param aPosition - Validates the end of a context.
  212.    */
  213.   NS_IMETHOD EndContext(PRInt32 aPosition) = 0;
  214.   
  215.   /**
  216.    * @update 01/09/2003 harishd
  217.    * @param aTag - Check if this tag is enabled or not.
  218.    */
  219.   NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn) = 0;
  220.  
  221.    /**
  222.    * This method is called when parser is about to begin
  223.    * synchronously processing a chunk of tokens. 
  224.    */
  225.   NS_IMETHOD WillProcessTokens(void) = 0;
  226.  
  227.   /**
  228.    * This method is called when parser has
  229.    * completed processing a chunk of tokens. The processing of the
  230.    * tokens may be interrupted by returning NS_ERROR_HTMLPARSER_INTERRUPTED from
  231.    * DidProcessAToken.
  232.    */
  233.   NS_IMETHOD DidProcessTokens() = 0;
  234.  
  235.   /**
  236.    * This method is called when parser is about to
  237.    * process a single token
  238.    */
  239.   NS_IMETHOD WillProcessAToken(void) = 0;
  240.  
  241.   /**
  242.    * This method is called when parser has completed
  243.    * the processing for a single token.
  244.    * @return NS_OK if processing should not be interrupted
  245.    *         NS_ERROR_HTMLPARSER_INTERRUPTED if the parsing should be interrupted
  246.    */
  247.   NS_IMETHOD DidProcessAToken(void) = 0;
  248.  
  249.     /**
  250.    * This method is used to open a generic container in the sink.
  251.    *
  252.    * @update 4/1/98 gess
  253.    * @param  nsIParserNode reference to parser node interface
  254.    */     
  255.   NS_IMETHOD OpenContainer(const nsIParserNode& aNode) = 0;
  256.  
  257.   /**
  258.    *  This method gets called by the parser when a close
  259.    *  container tag has been consumed and needs to be closed.
  260.    *
  261.    * @param  aTag - The tag to be closed.
  262.    */     
  263.   NS_IMETHOD CloseContainer(const nsHTMLTag aTag) = 0;
  264.  
  265.   /**
  266.    * This gets called by the parser to contents to 
  267.    * the head container
  268.    *
  269.    */     
  270.   NS_IMETHOD AddHeadContent(const nsIParserNode& aNode) = 0;
  271.  
  272.   /**
  273.    * This gets called by the parser when you want to add
  274.    * a leaf node to the current container in the content
  275.    * model.
  276.    *
  277.    * @update 4/1/98 gess
  278.    * @param  nsIParserNode reference to parser node interface
  279.    */     
  280.   NS_IMETHOD AddLeaf(const nsIParserNode& aNode) = 0;
  281.  
  282.   /**
  283.    * This gets called by the parser when you want to add
  284.    * a leaf node to the current container in the content
  285.    * model.
  286.    *
  287.    * @update 4/1/98 gess
  288.    * @param  nsIParserNode reference to parser node interface
  289.    */     
  290.   NS_IMETHOD AddComment(const nsIParserNode& aNode) = 0;
  291.  
  292.   /**
  293.    * This gets called by the parser when you want to add
  294.    * a leaf node to the current container in the content
  295.    * model.
  296.    *
  297.    * @update 4/1/98 gess
  298.    * @param  nsIParserNode reference to parser node interface
  299.    */     
  300.   NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode) = 0;
  301.  
  302.   /**
  303.    * This method is called by the parser when it encounters
  304.    * a document type declaration.
  305.    *
  306.    * XXX Should the parser also part the internal subset?
  307.    *
  308.    * @param  nsIParserNode reference to parser node interface
  309.    */
  310.   NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode) = 0;
  311.  
  312.   /**
  313.    * This gets called by the parser to notify observers of
  314.    * the tag
  315.    *
  316.    * @param aErrorResult the error code
  317.    */
  318.   NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) = 0;
  319.  
  320.   /**
  321.    * Call this method to determnine if a FORM is on the sink's stack
  322.    *
  323.    * @return PR_TRUE if found else PR_FALSE
  324.    */
  325.   NS_IMETHOD_(PRBool) IsFormOnStack() = 0;
  326.  
  327. };
  328.  
  329. #endif /* nsIHTMLContentSink_h___ */
  330.  
  331.